package SingletonPattern;

//静态内部类 Effiective Java也推荐的这种方式。 
public class Singleton4 {

	private Singleton4(){}
	
	//静态内部类
	private static class SingletonInstance{
		private static final Singleton4 instance = new Singleton4(); 
	}
	
	public static Singleton4 getInstance(){
		return SingletonInstance.instance;
	}
	
	public static void main(String[] args) {
		Singleton4 s1 = Singleton4.getInstance();
		Singleton4 s2 = Singleton4.getInstance();
		System.out.println(s1 == s2);
	}

}
